package leetcode_501_600;

public class LeeCode_504 {
    public static void main(String[] args) {
//        System.out.println(convertToBase7(100));
        System.out.println(convertToBase7(-7));
    }
    private static String convertToBase7(int num) {
        if (num == 0){
            return "0";
        }
        StringBuilder ans = new StringBuilder();
        boolean flag = false;
        if (num < 0){
            flag = true;
            num *= -1;
        }
        while (num > 0){
            ans.insert(0, (num % 7));
            num /= 7;
        }
        if (flag)
            ans.insert(0, "-");
        return ans.toString();
    }
}
